package cn.ickck.law_paper_final.provider;

import cn.ickck.law_paper_final.model.entity.HouseLoan;
import org.apache.ibatis.jdbc.SQL;

/**
 * @Author: ck
 * @Description: 房贷更新
 * @Date: Create in 12:22 2020/11/7
 */
public class HouseLoanProvider {
    public String updateHouseLoan(HouseLoan houseLoan)
    {
        return new SQL()
        {
            {
                UPDATE("house_loan");
                if (houseLoan.getName() != null) {
                    SET("name = #{name}");
                }
                if (houseLoan.getSex() != null) {
                    SET("sex = #{sex}");
                }
                if (houseLoan.getNation() != null) {
                    SET("nation = #{nation}");
                }
                if (houseLoan.getBirthDate() != null) {
                    SET("birth_date = #{birthDate}");
                }
                if (houseLoan.getCardNum() != null) {
                    SET("card_num = #{cardNum}");
                }
                if (houseLoan.getHomeAddress() != null) {
                    SET("home_address = #{homeAddress}");
                }
                if (houseLoan.getTel() != null) {
                    SET("tel = #{tel}");
                }
                if (houseLoan.getCurrentAddress() != null) {
                    SET("current_address = #{currentAddress}");
                }
                if (houseLoan.getWorkAddress() != null) {
                    SET("work_address = #{workAddress}");
                }
                if (houseLoan.getCoupleName() != null) {
                    SET("couple_name = #{coupleName}");
                }
                if (houseLoan.getCoupleSex() != null) {
                    SET("couple_sex = #{coupleSex}");
                }
                if (houseLoan.getNation() != null) {
                    SET("couple_nation = #{coupleNation}");
                }
                if (houseLoan.getCoupleBirthDate() != null) {
                    SET("couple_birth_date  = #{coupleBirthDate}");
                }
                if (houseLoan.getCoupleCardNum() != null) {
                    SET("couple_card_num = #{coupleCardNum}");
                }
                if (houseLoan.getCoupleHomeAddress() != null) {
                    SET("couple_home_address = #{coupleHomeAddress}");
                }
                if (houseLoan.getWeddingDate() != null) {
                    SET("wedding_date = #{weddingDate}");
                }
                if (houseLoan.getContractDate() != null) {
                    SET("contract_date = #{contractDate}");
                }
                if (houseLoan.getLoanDate() != null) {
                    SET("loan_date =  #{loanDate}");
                }
                if (houseLoan.getPayDay() != null) {
                    SET("pay_day = #{payDay}");
                }
                if (houseLoan.getPayWay() != null) {
                    SET("pay_way = #{payWay}");
                }
                if (houseLoan.getLoanSum() != null) {
                    SET("loan_sum = #{loanSum}");
                }
                if (houseLoan.getLoanGoal() != null) {
                    SET("loan_goal = #{loanGoal}");
                }
                if (houseLoan.getLoanTimeLimit() != null) {
                    SET("loan_time_limit = #{loanTimeLimit}");
                }
                if (houseLoan.getLoanRate() != null) {
                    SET("loan_rate = #{loanRate}");
                }
                if (houseLoan.getOverRate() != null) {
                    SET("over_rate = #{overRate}");

                }
                if (houseLoan.getDeadlineDate() != null) {
                    SET("deadline_date = #{deadlineDate}");

                }
                if (houseLoan.getPrincipal() != null) {
                    SET("principal = #{principal}");

                }
                if (houseLoan.getInterest() != null) {
                    SET("interest = #{interest}");

                }
                if (houseLoan.getAmount() != null) {
                    SET("amount = #{amount}");

                }
                if (houseLoan.getLitigationFee() != null) {
                    SET("litigation_fee = #{litigationFee}");
                }
                if (houseLoan.getSecurityFee() != null) {
                    SET("security_fee  = #{securityFee}");

                }
                if (houseLoan.getDeclaredFee() != null) {
                    SET("declared_fee = #{declaredFee}");

                }
                if (houseLoan.getLawyerFee() != null) {
                    SET("lawyer_fee = #{lawyerFee}");

                }
                if (houseLoan.getGuarantee() != null) {
                    SET("guarantee = #{guarantee}");

                }
                if (houseLoan.getGuaranteeNature() != null) {
                     SET("guarantee_nature = #{guaranteeNature}");
                }
                if (houseLoan.getGuaranteePeriod() != null) {
                    SET("guarantee_period = #{guaranteePeriod}");

                }
                if (houseLoan.getMortgageWay() != null) {
                    SET("mortgage_way = #{mortgageWay}");
                }

                if (houseLoan.getMortgageLocation() != null) {
                    SET("mortgage_location =  #{mortgageLocation}");
                }
                if (houseLoan.getMortgageDate() != null) {
                    SET("mortgage_date = #{mortgageDate}");

                }
                if (houseLoan.getMortgageNum() != null) {
                    SET("mortgage_num = #{mortgageNum}");

                }
                if (houseLoan.getMortgageCardNum() != null) {
                    SET("mortgage_card_num = #{mortgageCardNum}");
                }
                if (houseLoan.getFinancialReportNo() != null) {
                    SET("financial_report_no =  #{financialReportNo}");
                }
                if (houseLoan.getLawsuitNum() != null) {
                   SET("lawsuit_num = #{lawsuitNum}");
                }
                if (houseLoan.getExecuteNum() != null) {
                   SET("execute_num = #{executeNum}");
                }
                if (houseLoan.getJudgePrincipal() != null)
                {
                    SET("judge_principal = #{judgePrincipal}");

                }
                if(houseLoan.getJudgeInterest()!=null)
                {
                    SET("judge_interest = #{judgeInterest}");

                }
                if(houseLoan.getCourtLocation()!=null)
                {
                    SET("court_location = #{courtLocation}");

                }
                if(houseLoan.getAccuserAddress()!= null)
                {
                    SET("accuser_address =  #{accuserAddress}");

                }
                if(houseLoan.getAccuserPeople() != null)
                {
                    SET("accuser_people =#{accuserPeople    } ");

                }
                if(houseLoan.getCompanyName() != null)
                {
                    SET("company_name = #{companyName}");

                }
                if(houseLoan.getCompanyAddress()!=null)
                {
                    SET("company_address = #{companyAddress}");

                }
                if(houseLoan.getLegalPersonName()!=null)
                {
                    SET("legal_person_name =  #{legalPersonName}");


                }
                if(houseLoan.getLegalPersonPosition()!=null)
                {
                    SET("legal_person_position = #{legalPersonPosition}");

                }
                if(houseLoan.getPaperSignDate()!=null)
                {
                    SET("paper_sign_date = #{paperSignDate}");
                }
                if(houseLoan.getLoanStartDate()!=null)
                {
                    SET("loan_start_date = #{loanStartDate}");

                }
                if(houseLoan.getLoanEndDate()!=null)
                {
                    SET("loan_end_date  =  #{loanEndDate}");

                }


                WHERE("id = #{id}");





            }
        }.toString();
    }
}
